package org.budo.maven.plugin.assembly.mojo;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.budo.maven.plugin.assembly.mojo.util.MojoGitLogUtil;

import lombok.Getter;
import lombok.Setter;

/**
 * @author lmw
 */
@Mojo( //
        name = "budo-git-log", //
        defaultPhase = LifecyclePhase.INITIALIZE, //
        threadSafe = true, //
        requiresDependencyResolution = ResolutionScope.COMPILE //
)
@Getter
@Setter
public class BudoMavenAssemblyGitLogMojo extends AbstractMojo {
    @Parameter(defaultValue = "${project}", readonly = true, required = true)
    private MavenProject project;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        this.getLog().info("#33 BudoMavenAssemblyGitLogMojo#execute project.artifact=" + this.getProject().getArtifact() //
                + ", project.base=" + this.getProject().getBasedir() + ", this=" + this);

        // 写入git版本，到 resources
        MojoGitLogUtil.writeGitLogToClasses(this.getProject(), this.getLog());
    }
}